hotkey = "space"
--Horsetype = {121 SL } 
Horsetype = 121
Skeletaltype = 793 


function main()
UO.Macro(1,0,"All Follow Me")
if ContaHorse() ~= false then 
UseLastObject(idhorse) 
else 
print("cavallo non trovato o troppo distante") end
end 

function ContaHorse()
local cnt = UO.ScanItems(true)-1 
for i=0,cnt do
local id,type,kind,contid,x,y,z,stack,rep,col = UO.GetItem(i)
if type == Horsetype or type == Skeletaltype then
idhorse = id
if math.max(math.abs(UO.CharPosX - x), math.abs(UO.CharPosY - y)) <= 1 then return true end
end
end
return false
end

function UseLastObject(LObjectID)
UO.LObjectID = LObjectID
UO.Macro(17,0)
end

repeat 
wait (5)
if getkey(hotkey) then
main()
end
until false == true
